package com.core.zyyz.pcmc.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.core.common.utils.DateUtils;
import com.core.zyyz.pcmc.domain.PcmcApplication;
import com.core.zyyz.pcmc.mapper.PcmcApplicationMapper;
import com.core.zyyz.pcmc.service.PcmcApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 应用Service业务层处理
 *
 * @author core
 * @date 2024-10-21
 */
@Service
public class PcmcApplicationServiceImpl implements PcmcApplicationService
{
    @Autowired
    private PcmcApplicationMapper pcmcApplicationMapper;

    /**
     * 查询应用
     *
     * @param appCode 应用主键
     * @return 应用
     */
    @Override
    public PcmcApplication selectPcmcApplicationByAppCode(String appCode)
    {
        return pcmcApplicationMapper.selectPcmcApplicationByAppCode(appCode);
    }

    /**
     * 查询应用列表
     *
     * @param pcmcApplication 应用
     * @return 应用
     */
    @Override
    public List<PcmcApplication> selectPcmcApplicationList(PcmcApplication pcmcApplication)
    {
        return pcmcApplicationMapper.selectPcmcApplicationList(pcmcApplication);
    }

    /**
     * 新增应用
     *
     * @param pcmcApplication 应用
     * @return 结果
     */
    @Override
    public int insertPcmcApplication(PcmcApplication pcmcApplication) throws Exception {
        PcmcApplication application = pcmcApplicationMapper.selectPcmcApplicationByAppCode(pcmcApplication.getAppCode());
        if (application != null){
            throw new Exception("应用编号已存在！");
        }else {
            return pcmcApplicationMapper.insertPcmcApplication(pcmcApplication);
        }
    }

    /**
     * 修改应用
     *
     * @param pcmcApplication 应用
     * @return 结果
     */
    @Override
    public int updatePcmcApplication(PcmcApplication pcmcApplication)
    {
        return pcmcApplicationMapper.updatePcmcApplication(pcmcApplication);
    }

    /**
     * 批量删除应用
     *
     * @param appCodes 需要删除的应用主键
     * @return 结果
     */
    @Override
    public int deletePcmcApplicationByAppCodes(String[] appCodes)
    {
        return pcmcApplicationMapper.deletePcmcApplicationByAppCodes(appCodes);
    }

    /**
     * 删除应用信息
     *
     * @param appCode 应用主键
     * @return 结果
     */
    @Override
    public int deletePcmcApplicationByAppCode(String appCode)
    {
        return pcmcApplicationMapper.deletePcmcApplicationByAppCode(appCode);
    }
}
